package com.ferry.example;

import com.ferry.common.util.concurrent.NamedThreadFactory;
import io.netty.util.HashedWheelTimer;
import io.netty.util.Timeout;
import io.netty.util.TimerTask;

import java.util.concurrent.TimeUnit;

/**
 * Created by daiyong
 * 测试netty 时间轮
 */
public class TestHashdWheelTimer {

	public static void main(String[] args) throws InterruptedException {
		//时间轮 50毫秒一跳
		HashedWheelTimer timeoutWatcher = new HashedWheelTimer( new NamedThreadFactory("futures.timeout.scanner", true),
				50, TimeUnit.MILLISECONDS,
				4096);

		timeoutWatcher.newTimeout(new TimerTask() {
			@Override
			public void run(Timeout timeout) throws Exception {
				System.out.println("hello。。。");
			}
		}, 10, TimeUnit.SECONDS);

		Thread.sleep(Integer.MAX_VALUE);
	}

}
